/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.upn.sigemfi.sac.be;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Colao
 */
@Entity
@Table(name = "SAC_AUTONOMIA")
@NamedQueries({@NamedQuery(name = "Autonomia.findAll", query = "SELECT a FROM Autonomia a"), @NamedQuery(name = "Autonomia.findByIdAutonomia", query = "SELECT a FROM Autonomia a WHERE a.idAutonomia = :idAutonomia"), @NamedQuery(name = "Autonomia.findByFidPltSucursal", query = "SELECT a FROM Autonomia a WHERE a.fidPltSucursal = :fidPltSucursal"), @NamedQuery(name = "Autonomia.findByMontoMaximo", query = "SELECT a FROM Autonomia a WHERE a.montoMaximo = :montoMaximo"), @NamedQuery(name = "Autonomia.findByNota", query = "SELECT a FROM Autonomia a WHERE a.nota = :nota")})
public class Autonomia implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID_AUTONOMIA")
    private Long idAutonomia;
    @Column(name = "FID_PLT_SUCURSAL")
    private BigInteger fidPltSucursal;
    @Column(name = "MONTO_MAXIMO")
    private Double montoMaximo;
    @Column(name = "NOTA")
    private String nota;
    @OneToMany(mappedBy = "fidSacAutonomia", fetch = FetchType.LAZY)
    private List<SolicitudCredito> solicitudCreditoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "autonomia", fetch = FetchType.LAZY)
    private List<RiesgoAutonomia> riesgoAutonomiaCollection;
    @JoinColumn(name = "FID_SAC_NIVEL_APROBACION", referencedColumnName = "ID_NIVEL_APROBACION")
    @ManyToOne(fetch = FetchType.LAZY)
    private NivelAprobacion fidSacNivelAprobacion;
    @JoinColumn(name = "FID_SAC_SUB_PRODUCTO", referencedColumnName = "ID_SUB_PRODUCTO")
    @ManyToOne(fetch = FetchType.LAZY)
    private SubProducto fidSacSubProducto;

    public Autonomia() {
    }

    public Autonomia(Long idAutonomia) {
        this.idAutonomia = idAutonomia;
    }

    public Long getIdAutonomia() {
        return idAutonomia;
    }

    public void setIdAutonomia(Long idAutonomia) {
        this.idAutonomia = idAutonomia;
    }

    public BigInteger getFidPltSucursal() {
        return fidPltSucursal;
    }

    public void setFidPltSucursal(BigInteger fidPltSucursal) {
        this.fidPltSucursal = fidPltSucursal;
    }

    public Double getMontoMaximo() {
        return montoMaximo;
    }

    public void setMontoMaximo(Double montoMaximo) {
        this.montoMaximo = montoMaximo;
    }

    public String getNota() {
        return nota;
    }

    public void setNota(String nota) {
        this.nota = nota;
    }

    public List<SolicitudCredito> getSolicitudCreditoCollection() {
        return solicitudCreditoCollection;
    }

    public void setSolicitudCreditoCollection(List<SolicitudCredito> solicitudCreditoCollection) {
        this.solicitudCreditoCollection = solicitudCreditoCollection;
    }

    public List<RiesgoAutonomia> getRiesgoAutonomiaCollection() {
        return riesgoAutonomiaCollection;
    }

    public void setRiesgoAutonomiaCollection(List<RiesgoAutonomia> riesgoAutonomiaCollection) {
        this.riesgoAutonomiaCollection = riesgoAutonomiaCollection;
    }

    public NivelAprobacion getFidSacNivelAprobacion() {
        return fidSacNivelAprobacion;
    }

    public void setFidSacNivelAprobacion(NivelAprobacion fidSacNivelAprobacion) {
        this.fidSacNivelAprobacion = fidSacNivelAprobacion;
    }

    public SubProducto getFidSacSubProducto() {
        return fidSacSubProducto;
    }

    public void setFidSacSubProducto(SubProducto fidSacSubProducto) {
        this.fidSacSubProducto = fidSacSubProducto;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idAutonomia != null ? idAutonomia.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Autonomia)) {
            return false;
        }
        Autonomia other = (Autonomia) object;
        if ((this.idAutonomia == null && other.idAutonomia != null) || (this.idAutonomia != null && !this.idAutonomia.equals(other.idAutonomia))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.upn.sigemfi.sac.be.Autonomia[idAutonomia=" + idAutonomia + "]";
    }

}
